﻿using System;
using System.Data;
using System.Data.SqlClient;

namespace SIS.DataAccess
{
	/// <summary>
	/// Author: hieunv
	/// </summary>
	class Course : System.Data.DataTable
	{
		public const string COURSE_ID = "course_id";
		public const string TITLE = "title";
		public const string DEPARTMENT_NAME = "dept_name";
		public const string CREADITS = "credits";
		public Course()
			: base("Course")
		{
			var id = new System.Data.DataColumn(COURSE_ID, typeof(string));
			id.Unique = true;
			id.AllowDBNull = false;

			var title = new System.Data.DataColumn(TITLE, typeof(string));
			title.AllowDBNull = true;

			var departmentName = new System.Data.DataColumn(DEPARTMENT_NAME, typeof(string));
			departmentName.AllowDBNull = true;

			var credits = new System.Data.DataColumn(CREADITS, typeof(int));
			credits.AllowDBNull = true;

			this.Columns.Add(id);
			this.Columns.Add(title);
			this.Columns.Add(departmentName);
			this.Columns.Add(credits);

			this.PrimaryKey = new System.Data.DataColumn[] { id };
		}

		public static DataTable GetCourseIds()
		{
			var courseIds = new DataTable();
			DataServices.ExecuteQuery(QueryType.INSERT, CommandType.Text, "SELECT course_id FROM course", null, courseIds);
			return courseIds;
		}
	}
}
